package com.ruoyi.web.controller.system;

import java.util.List;

import com.ruoyi.common.core.domain.entity.RiskMonitoring;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.IRiskMonitoringService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 风险监控Controller
 * 
 * @author ess
 * @date 2021-10-18
 */
@RestController
@RequestMapping("/system/riskMonitoring")
public class RiskMonitoringController extends BaseController
{
    @Autowired
    private IRiskMonitoringService riskMonitoringService;

    /**
     * 查询风险监控列表
     */
    @PreAuthorize("@ss.hasPermi('system:monitoring:list')")
    @GetMapping("/list")
    public TableDataInfo list(RiskMonitoring riskMonitoring)
    {
        startPage();
        List<RiskMonitoring> list = riskMonitoringService.selectRiskMonitoringList(riskMonitoring);
        return getDataTable(list);
    }

    /**
     * 导出风险监控列表
     */
    @PreAuthorize("@ss.hasPermi('system:monitoring:export')")
    @Log(title = "风险监控", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RiskMonitoring riskMonitoring)
    {
        List<RiskMonitoring> list = riskMonitoringService.selectRiskMonitoringList(riskMonitoring);
        ExcelUtil<RiskMonitoring> util = new ExcelUtil<RiskMonitoring>(RiskMonitoring.class);
        return util.exportExcel(list, "风险监控数据");
    }

    /**
     * 获取风险监控详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:monitoring:query')")
    @GetMapping(value = "/{riskId}")
    public AjaxResult getInfo(@PathVariable("riskId") String riskId)
    {
        return AjaxResult.success(riskMonitoringService.selectRiskMonitoringByRiskId(riskId));
    }

    /**
     * 新增风险监控
     */
    @PreAuthorize("@ss.hasPermi('system:monitoring:add')")
    @Log(title = "风险监控", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RiskMonitoring riskMonitoring)
    {
        return toAjax(riskMonitoringService.insertRiskMonitoring(riskMonitoring));
    }

    /**
     * 修改风险监控
     */
    @PreAuthorize("@ss.hasPermi('system:monitoring:edit')")
    @Log(title = "风险监控", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RiskMonitoring riskMonitoring)
    {
        return toAjax(riskMonitoringService.updateRiskMonitoring(riskMonitoring));
    }

    /**
     * 删除风险监控
     */
    @PreAuthorize("@ss.hasPermi('system:monitoring:remove')")
    @Log(title = "风险监控", businessType = BusinessType.DELETE)
	@DeleteMapping("/{riskIds}")
    public AjaxResult remove(@PathVariable String[] riskIds)
    {
        return toAjax(riskMonitoringService.deleteRiskMonitoringByRiskIds(riskIds));
    }
}
